package sample.business.util;


import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;

import java.io.File;
import java.io.IOException;

/**
 * Created by lilongfei on 2016/12/23.
 */
public class XmlResolver {

    public static void writeDependencyXml(String content,String xmlPath){
        SAXBuilder saxBuilder = new SAXBuilder();
        try {
            Document document = saxBuilder.build(new File(xmlPath));
            Element root = document.getRootElement();
            if (root.getChild("dependencies") == null){
                root.indexOf(root.getChild("properties"));
            }
        } catch (JDOMException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws JDOMException, IOException {
        SAXBuilder saxBuilder = new SAXBuilder();
        Document document = saxBuilder.build(new File("/Users/lilongfei/dev/idea/ktopenapi/pom.xml"));
        Element root = document.getRootElement();
        System.out.println(root.getChildren("properties"));
    }

}
